package com.zhuzg.aop;

import com.zhuzg.mapper.MesLogMapper;

import com.zhuzg.pojo.po.MesLogDto;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Aspect
@Component
public class logInterceptor {

    @Autowired
    MesLogMapper mesLogMapper;


    @Around("execution(* com.zhuzg.service.impl.*.*(..))")
    public  Object aroundAdvice(ProceedingJoinPoint pjp) throws Throwable {

        Date startTime = new Date();

        MethodSignature signature = (MethodSignature) pjp.getSignature();
        // 被调用的方法名称
        String name = signature.getMethod().getName();

        Object o = pjp.proceed();


       // mesLogMapper.insert(new MesLogDto(name,o,startTime,new Date()));
        //返回执行的结果
        return o;


    }

}
